<?php
/**
 *author:韩帅
 *createtime:2017/6/20 9:48
 *description:
 */
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CardType extends Model
{
    /**
     * 定义主键字段
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * 定义表名，不含前缀
     *
     * @var string
     */
    protected $table      = 'wd_card_type';

    /**
     * 定义拒绝保存的字段
     *
     * @var array
     */
    protected $guarded    = ['id'];

    /**
     * 开启laravel默认的时间记录
     *
     * @var bool
     */
    public $timestamps = true;

    /**
     * 定义启用的状态
     */
    const STATUS_BEGIN = 1;

    /**
     * 定义禁用的状态
     */
    const STATUS_STOP  = 0;

    /**
     * 定义已删除的状态
     */
    const ISDELETE_YES  = 1;

    /**
     * 定义未删除的状态
     */
    const ISDELETE_NO   = 0;

    /**
     * 银行卡类型转化
     */
    public static function translate($data)
    {
        $newArr = [];

        $newArr['total'] = $data['total'];
        $newArr['per_page'] = $data['per_page'];
        $newArr['current_page'] = $data['current_page'];
        $newArr['last_page'] = $data['last_page'];
        foreach ($data['data'] as $k => $v) {
            $newArr['card_type_list'][] = ['id' => $v['id'], 'name' => $v['name'],'logo' => $v['logo']];

        }
        return $newArr;
    }
}